package besta.moon.command;

import besta.moon.MoonConnection;
import besta.moon.statement.MoonStatement;
import besta.moon.MoonLogger;
import besta.moon.MoonCommand;
import besta.moon.engine.table.Column;
import besta.moon.engine.table.Columns;
import besta.moon.sql.parser.SQLTokenizer;

public class CommandCreateView extends MoonCommand {

    private final Columns columns = new Columns();
    public String sql;

    public CommandCreateView(MoonLogger log, String name) {
        super(log);
        this.type = SQLTokenizer.VIEW;
        this.name = name;
    }

    void addColumn(Column column) {
        columns.add(column);
    }

    @Override
    public void executeImpl(MoonConnection con, MoonStatement st) throws Exception {
        con.getDatabase(false).createView(con, name, sql);
    }

}
